<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>configurable</title>
	</head>
	<body>
		<script>
			let obj = {
				name: 'jack',
				age: 18,
			}
			let vm = {}
			// 遍历obj对象key,将obj对象属性绑定到vm对象上
			for(const key in obj){
				Object.defineProperty(vm, key, {
					get() {
						return obj[key]
					},
					set(newValue) {
						if(obj[key] === newValue){
							return
						}
						obj[key] = newValue
					},
				})
			}
			// Object.keys(obj).forEach(key => {
			// 	Object.defineProperty(vm, key, {
			// 		get() {
			// 			return obj[key]
			// 		},
			// 		set(newValue) {
			// 			if(obj[key] === newValue){
			// 				return
			// 			}
			// 			obj[key] = newValue
			// 		},
			// 	})
			// })
		</script>
	</body>
</html>
